//
//  KKTableFooterView.m
//  FreightAssistant
//
//  Created by leo on 15/11/8.
//  Copyright © 2015年 leo. All rights reserved.
//

#import "KKTableFooterView.h"

@implementation KKTableFooterView

+ (instancetype)footerViewOfTitleLabelWithTableView:(UITableView*)tableView {
    
    KKTableFooterView *footerView = [[KKTableFooterView alloc] initWithFrame: CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 22)];
    footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    footerView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"inner_table_footer"]];
    
    UILabel *titleLabel = [[UILabel alloc] initWithFrame: CGRectMake(15, 0, CGRectGetWidth(footerView.bounds) - 30, CGRectGetHeight(footerView.bounds))];
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.textAlignment = NSTextAlignmentLeft;
    titleLabel.text = @"总金额:¥2928.0";
    titleLabel.font = [UIFont systemFontOfSize: 15];
    titleLabel.textColor = [UIColor redColor];
    titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight;
    [footerView addSubview: titleLabel];
    footerView.kk_titleLabel = titleLabel;
    return footerView;
}

+ (instancetype)footerViewOfSubmitButtonWithTableView:(UITableView*)tableView {
    
    KKTableFooterView *footerView = [[KKTableFooterView alloc] initWithFrame: CGRectMake(0, 0, CGRectGetWidth(tableView.bounds), 100)];
    footerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    UIButton *submitButton = [UIButton buttonWithType: UIButtonTypeCustom];
    submitButton.frame = CGRectMake(15, 35, CGRectGetWidth(footerView.bounds) - 30, 40);
    submitButton.layer.cornerRadius = 5;
    submitButton.layer.masksToBounds = true;
    [submitButton setBackgroundImage: [UIImage imageNamed: @"button_save_item"] forState: UIControlStateNormal];
    [submitButton setTitle: @"保存" forState: UIControlStateNormal];
    submitButton.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [footerView addSubview: submitButton];
    footerView.kk_submitButton = submitButton;
    
    tableView.tableFooterView = footerView;
    
    return footerView;
}

@end
